<template>
  <div class="container">
     <topSearch :form='form' :showAdd="false" @searchlist='searchlist' @resetform='resetform'></topSearch>
  
    <el-row>
      <el-table :data="tableData" border style="width: 100%;margin-top:20px" size="small">
        <el-table-column
          prop="object_type"
          label="审核类型"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="object_id"
          label="审核对象"
          show-overflow-tooltip
        ></el-table-column>

        <el-table-column
          prop="school_id.short_title"
          label="驾校简称"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="school_id.title"
          label="企业名称"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="create_time"
          label="提交时间"
          show-overflow-tooltip
        >
        </el-table-column>

        <el-table-column prop="date" label="操作">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="editItem(scope.row)"
              v-if="checkPermission(['examineApplyReceive'])"
              >领取</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-row>
        <el-col :span="24" class="pagination">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[10, 20]"
            :page-size="10"
            background
            :current-page.sync="page"
            layout="total, sizes, prev, pager, next"
            :total="pagination.total"
          >
          </el-pagination>
        </el-col>
      </el-row>
    </el-row>
  </div>
</template>

<script type="text/javascript">
import { examine, examineReceive } from "@/api/institutional";
import topSearch from "@/components/topSearch";
import checkPermission from "@/utils/permission"; // 权限判断函数
export default {
  data() {
    return {
      course: 1, //科目一
      isshowDialog: false,
      dialogTitle: "新增题库",
      formtype: 0,
      page: 1,
      rows: 10,
      form: {
        status: null,
        chapter: null,
        type: "",
        is_charge: null,
        keyWord: null,
      },
      statusOptions: [
        {
          lable: "驾校",
          id: 1,
        },
        {
          lable: "机构",
          id: 2,
        },
        {
          lable: "平台",
          id: 3,
        },
        {
          lable: "活动",
          id: 4,
        },
        {
          lable: "训练场",
          id: 5,
        },
        {
          lable: "考场",
          id: 6,
        },
        {
          lable: "教练",
          id: 7,
        },
        {
          lable: "班型",
          id: 8,
        },
      ],

      tableData: [],
      chapterOptions: [],
      pagination: {},
      dialogdata: null,
    };
  },
  components: {
    topSearch,
  },
  created() {
    this.getData();
  },
  methods: {
    checkPermission,
    handleSizeChange(val) {
      this.rows = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getData();
    },
    searchlist() {
       this.page= 1,
      this.getData();
    },
    resetform() {
   
      this.getData();
    },

    //编辑
    async editItem(val) {
      let data = await examineReceive({ id: val.id });
      if (data.code == "0000") {
        this.$message({
          type: "success",
          message: data.msg,
        });
        this.getData();
      }
    },

    //获取列表
    async getData() {
      let params = {
        page: this.page,
        rows: this.rows,
      };
      if (this.form.status) {
        params.status = this.form.status;
      }
      if (this.form.chapter) {
        params.chapter = this.form.chapter;
      }
      if (this.form.type !== "") {
        params.type = this.form.type;
      }
      if (this.form.is_charge) {
        params.is_charge = this.form.is_charge;
      }
      if (this.form.keyWord) {
        params.keyword = this.form.keyWord;
      }
      let data = await examine(params);
      let datainfo = data.data;
      this.tableData = datainfo.list;
      this.pagination = datainfo.page;
    },
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
.topSearch {
  overflow: hidden;
  .el-button {
    float: left;
  }
  .el-form {
    float: right;
  }
  .rightbtn{
    float: right;
  }
}
</style>
